package top.api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.api.annotation.SystemLog;
import top.api.common.ResponseResult;
import top.api.domain.entity.User;
import top.api.service.UserService;

@RestController
@RequestMapping("/user")
@Api(tags = "用户")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 获取用户信息
     * @return
     */
    @GetMapping("/userInfo")
    @ApiOperation(value = "获取用户信息",notes = "需要token")
    public ResponseResult userInfo(){
        return userService.userInfo();
    }

    /**
     * 更新用户信息
     * @param user
     * @return
     */
    @PutMapping("/userInfo")
    @ApiOperation(value = "更新用户信息",notes = "需要token")
    public ResponseResult updateUserInfo(@RequestBody User user){
        return userService.updateUserInfo(user);
    }

    @PostMapping("/register")
    @ApiOperation(value = "注册")
    @SystemLog("用户注册")
    public ResponseResult register(@RequestBody User user){
        return userService.register(user);
    }

}
